const graph = {
    "A":["B","C"],
    "B":["A","C","D"],
    "C":["A","B","D","E"],
    "D":["B","C","E","F"],
    "E":["C","D"],
    "F":["D"]
}

function BFS(graph,s){
    let queue = []
    queue.unshift(s)
    let isVist = {}
    for(x in graph){
        isVist[x] = false
    } 
    isVist[s] = true
    while(queue.length > 0){
        let vertex = queue.pop()
        let nodes = graph[vertex]
        nodes.forEach(node => {
            if(!isVist[node]){
                queue.unshift(node)
                isVist[node] = true
            }
        });
        console.log(vertex)
    }
}
BFS(graph,"E")